package crawler.web.engine.config;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author waynechen May 23, 2012 1:44:34 PM
 */
public class SpringUtils {
	private static ClassPathXmlApplicationContext classPathXmlApplicationContext;
	static {
		classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
	}

	@SuppressWarnings("unchecked")
	public static <T> T getBean(String name, Class<T> clazz) {
		return (T) classPathXmlApplicationContext.getBean(name);
	}

	@SuppressWarnings("unchecked")
	public static <T> T getBean(String name) {
		return (T) classPathXmlApplicationContext.getBean(name);
	}

	public static Integer getBeanInt(String name) {
		return (Integer) classPathXmlApplicationContext.getBean(name);
	}

	public static String getBeanStr(String name) {
		return (String) classPathXmlApplicationContext.getBean(name);
	}
}
